package smartcampus.scjava.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import smartcampus.scjava.POJO.DO.Xuesheng;

import java.util.Collection;
import java.util.List;

public interface XueshengMapper {

    @Select("SELECT * FROM xuesheng where xuehao like concat('%',#{xuehao},'%') and" +
            " xingming like concat('%',#{xingming},'%') ORDER BY id  DESC")
    List<Xuesheng> selectAll(Xuesheng xuesheng);

    @Insert("INSERT INTO xuesheng(xuehao, xingming, xueyuan, zhuanye, xingbie, nianling, dianhua, zhuangtai) " +
            "VALUES(#{xuehao}, #{xingming}, #{xueyuan}, #{zhuanye}, #{xingbie}, #{nianling}, #{dianhua}, #{zhuangtai})")
    void insert(Xuesheng xuesheng);

    @Delete("DELETE FROM xuesheng WHERE id = #{id}")
    void deleteById(Integer id);

    @Update("UPDATE xuesheng SET xuehao=#{xuehao}, xingming=#{xingming}, xueyuan=#{xueyuan}, zhuanye=#{zhuanye}, xingbie=#{xingbie}, " +
            "nianling=#{nianling}, dianhua=#{dianhua}, zhuangtai=#{zhuangtai} WHERE id = #{id}")
    void updateById(Xuesheng xuesheng);

    @Select("SELECT * FROM xuesheng")
    List<Xuesheng> findAll();

    @Select("SELECT * FROM xuesheng WHERE zhuangtai = '已就业'")
    Collection<Object> findEmployedStudents();

    @Select("SELECT * FROM xuesheng WHERE zhuangtai = '未就业'")
    Collection<Object> findUnemployedStudents();
    @Select("SELECT xuehao FROM xuesheng where zhuangtai= '已就业'")
    List<String> selectAllXuehao();
    @Select("SELECT xingming FROM xuesheng WHERE xuehao = #{xuehao}")
    String selectNameByXuehao(String xuehao);
    @Select("SELECT COUNT(*) FROM xuesheng")
    int totalPage();
}
